using System.Security.Principal;
using KL.Standard.Model.Attribute;
using KL.Standard.Model.ViewModels.OutResult;
using Newtonsoft.Json;

namespace KL.Standard.Model.Infrastructure;

/// <summary>
/// 当前用户的信息
/// </summary>
public class CurUserInfo 
{

    public CurUserInfo()
    {

    }

    public CurUserInfo(AccountVM info)
    {
        //this.id = info.id;
        this.loginID = info.loginID;
        this.nickName = info.nickName;
        this.roleID = info.roleID;
        this.email = info.email;
        this.mobile = info.mobile;
        this.avatar = "";
        this.deptName = info.deptName;
        this.deptCode = info.deptCode;
        this.companyCode = info.companyCode;
        this.companyName = info.companyName;
        this.deptFullName = info.deptFullName;

    }
    #region 用户基本信息
    [JsonIgnore]
    public long id { set; get; }
    [ClaimConfig]
    public string loginID { set; get; }
    //public string password { set; get; }
    [ClaimConfig]
    public string nickName { set; get; }
    [ClaimConfig]
    public string mobile { set; get; }
    [ClaimConfig]
    public string email { set; get; }
    //[ClaimConfig]
    public string aToken { set; get; }
    [ClaimConfig]
    public string avatar { set; get; }

    public int isSystem { set; get; }
    //public int loginCount { set; get; }

    //public string loginLastIP { set; get; }

    //public int isLock { set; get; }
    //public int isDelete { set; get; }
    //public string remark { set; get; }
    //public int isSystem { set; get; }
    #endregion

    #region 部门
    [JsonIgnore]
    public long companyID { set; get; }
    [ClaimConfig(ShowName = "ftyCode")]
    public string companyCode { set; get; }
    //[ClaimConfig]
    public string companyName { set; get; }

    public long deptID { set; get; }
    [ClaimConfig]
    public string deptCode { set; get; }
    //[ClaimConfig]
    public string deptName { set; get; }
    [JsonIgnore]
    public string deptFullName { set; get; }

    #endregion

    #region 职位
    [JsonIgnore]
    public long positionID { set; get; }
    [JsonIgnore]
    public string positionName { set; get; }


    #endregion

    #region 角色
    [ClaimConfig(FieldType = "int")]
    public long roleID { set; get; }
    //[ClaimConfig]
    public string roleName { set; get; }
    [ClaimConfig]
    public string dsType { set; get; }
    #endregion

    #region 密钥

    public string cKey { set; get; }

    #endregion 

    public bool IsInRole(string role)
    {
        throw new NotImplementedException();
    }

    public bool isAdmin(out string companyCode)
    {
        companyCode = "";
        if (this.isSystem == 1)
        {
            if (!string.IsNullOrEmpty(this.companyCode))
                companyCode = this.companyCode;
            return true;
        }
        else
        {
            return false;
        }
    }

    //        public int isSystem()
    //        {
    //            return this.loginID.ToLower().Equals("admin") ? 1 : 0;
    //        }
    [JsonIgnore]
    public IIdentity Identity { get; }
    //[JsonIgnore]
   // public ISysUserModel UserModel { get; }

   #region 本地設置
   [ClaimConfig]
   [JsonIgnore]
   public string lang { get; set; }
   #endregion

}